let obj = {
    a:1,
    b:2,
    c:{
        d:2,
        e:8
    }
}
/* 
 *  target 是指obj,k指 属性值 
 */
function isObject(obj){
    return obj !== null && typeof obj === "object"
}
function observe(obj){
    const  proxy = new Proxy(obj,{
        get(target,k){
            let v = target[k]
            if(isObject(target[k])){
               v = observe(obj[k])
            }
            console.log(k,'读取')
            return v;
        },
        set(target,k,val){
            if(target[k]!==val){
                target[k] = val
                console.log(k,'更改')
            }
        }
    })
    return proxy;
}


let proxy = observe(obj)
console.log(proxy.c.d)


console.log(proxy.ahh = 34)
console.log(proxy)